using MicroMsg.UI.Page;
using MicroMsg.UI.Util;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
namespace MicroMsg.UI.UserContrl
{
	public class LongTxtItem : UserControl
	{
		public static DependencyProperty ListItemProperty;
		internal Grid LayoutRoot;
		internal Paragraph sParagraph;
		private bool _contentLoaded;
		public string ItemObject
		{
			get
			{
				return (string)base.GetValue(LongTxtItem.ListItemProperty);
			}
			set
			{
				base.SetValue(LongTxtItem.ListItemProperty, value);
			}
		}
		public LongTxtItem()
		{
			this.InitializeComponent();
			BasePage topPage = PageManager.getInstance().GetTopPage();
			if (topPage is LongTxtShowPage)
			{
				LongTxtShowPage longTxtShowPage = topPage as LongTxtShowPage;
				if (longTxtShowPage.isSender)
				{
					this.LayoutRoot.set_Background(new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)));
					return;
				}
				this.LayoutRoot.set_Background(new SolidColorBrush(Color.FromArgb(255, 150, 207, 88)));
			}
		}
		static LongTxtItem()
		{
			LongTxtItem.ListItemProperty = DependencyProperty.Register("ItemObject", typeof(string), typeof(LongTxtItem), new PropertyMetadata(null, new PropertyChangedCallback(LongTxtItem.OnItemPropertyChanged)));
		}
		private static void OnItemPropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == LongTxtItem.ListItemProperty)
			{
				(dependencyObject_0 as LongTxtItem).OnListItemPropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		private void OnListItemPropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			this.RefreshItem(dependencyPropertyChangedEventArgs_0.get_NewValue() as LongTxtItem);
		}
		private void RefreshItem(LongTxtItem item)
		{
			this.sParagraph.get_Inlines().Clear();
			List<InLineResult> inLineResult = InlineElementHelper.GetInLineResult(this.ItemObject);
			int num = 0;
			using (List<InLineResult>.Enumerator enumerator = inLineResult.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					InLineResult current = enumerator.get_Current();
					if (current.mInline != null)
					{
						num++;
						this.sParagraph.get_Inlines().Add(current.mInline);
						if (num >= 400)
						{
							Run run = new Run();
							run.set_Text("......");
							this.sParagraph.get_Inlines().Add(run);
							break;
						}
					}
				}
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Chat/TooLongTxt/LongTxtItem.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.sParagraph = (Paragraph)base.FindName("sParagraph");
		}
	}
}
